package com.xs.api.impl;

import java.util.Random;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.xs.api.OrderServiceApi;
import com.xs.entity.Order;

@RestController
public class OrderServiceApiImpl implements OrderServiceApi {

	private Log log = LogFactory.getLog(OrderServiceApiImpl.class);



	@Autowired
	Environment environment;

	public String getPort() {
		return environment.getProperty("local.server.port");
	}

	@Override
	public String getOrders() {
		// TODO Auto-generated method stub
		return "GET ALL ORDERS ";
	}

	@Override
	public Order getOrderById(int orderId) {
		
		Order order = new Order();
		order.setOrderId(orderId);
		order.setMoney(new Random().nextDouble()*1000);
		order.setOrderName("采购订单");
		
		return order;
	}

	@Override
	public Order getOrderInfo(@RequestBody Order order) {


		order.setMoney(new Random().nextDouble()*1000);
		order.setOrderName("用户订单");
		
		return order;
	}

	


}
